package com.zhiche.lisa.bms.pojo.bo.quote;

import com.zhiche.lisa.bms.dao.model.fee.FeePayable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class MatchingResultList {

    private List<MatchingResult> firstMatchingResultList;

    private List<MatchingResult> allMatchingResultList;

    public List<MatchingResult> getFirstMatchingResultList() {
        return firstMatchingResultList;
    }

    public void setFirstMatchingResultList(List<MatchingResult> firstMatchingResultList) {
        this.firstMatchingResultList = firstMatchingResultList;
    }

    public List<MatchingResult> getAllMatchingResultList() {
        return allMatchingResultList;
    }

    public void setAllMatchingResultList(List<MatchingResult> allMatchingResultList) {
        this.allMatchingResultList = allMatchingResultList;
    }

    public void addMatchingResult(String ruleName,FeePayable feePayable,FleetQuotation fleetQuotation){
        if(Objects.isNull(firstMatchingResultList)) firstMatchingResultList = new ArrayList<>();
        if(Objects.isNull(allMatchingResultList)) allMatchingResultList = new ArrayList<>();

        MatchingResult matchingResult = new MatchingResult(ruleName,feePayable,fleetQuotation);

        for (MatchingResult result : firstMatchingResultList){
            //已经存在匹配的价格
            if(result.getFeePayable().getId().equals(feePayable.getId())){
                this.allMatchingResultList.add(matchingResult);
                return;
            }
        }

        firstMatchingResultList.add(matchingResult);
        allMatchingResultList.add(matchingResult);
    }
}
